package nbcp.base.utils;

import java.util.List;
import java.util.Map;

public   class DockerContainer {

    public static class HostConfigModel {
        public String NetworkMode;
    }

    public static class NetworkSettingModel {
        public String NetworkID;
        public String EndpointID;
        public String Gateway;
        public String IPAddress;
        public Integer IPPrefixLen;
        public String IPv6Gateway;
        public String MacAddress;
    }

    public static class NetworkSettingsModel {
        public Map<String, NetworkSettingModel> Networks;
    }

    public static class MountsModel {
        public String Type;
        public String Source;
        public String Destination;
        public String Mode;
        public Boolean RW;
        public String Propagation;
    }

    public String Id;
    public List<String> Names;
    public String Image;
    public String ImageID;
    public String Command;
    public Integer Created;
    public String State;
    public String Status;
    public HostConfigModel HostConfig;
    public NetworkSettingsModel NetworkSettings;
    public List<MountsModel> Mounts;


    public String getContainerName() {
        if (Names == null || Names.isEmpty()) {
            return "";
        }
        return Names.get(0).replace("/", "");
    }

    public String getContainerIp() {
        var values = NetworkSettings.Networks.values();
        if (values.isEmpty()) {
            return "";
        }
        return values.stream().findFirst().get().IPAddress;
    }
}
